# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=cvs
pkgver=1.11.23
pkgrel=2
pkgdesc="Concurrent Versions System - a source control system"
arch=('i686' 'x86_64')
license=('GPL')
url="http://cvs.nongnu.org/"
depends=('heimdal' 'zlib' 'libcrypt' 'libopenssl')
makedepends=('heimdal-devel' 'zlib-devel' 'gcc' 'libcrypt-devel' 'openssl-devel')
options=('staticlibs')
install=cvs.install
source=(ftp://ftp.gnu.org/non-gnu/cvs/source/stable/${pkgver}/${pkgname}-${pkgver}.tar.bz2
    cvs-1.11.1p1-bs.patch
    cvs-1.11.19-abortabort.patch
    cvs-1.11.19-comp.patch
    cvs-1.11.19-extzlib.patch
    cvs-1.11.19-logmsg.patch
    cvs-1.11.19-netbsd-tag.patch
    cvs-1.11.19-tagname.patch
    cvs-1.11.19-tmp.patch
    cvs-1.11.21-diff-kk.patch
    cvs-1.11.21-diff.patch
    cvs-1.11.21-proxy.patch
    cvs-1.11.21-sort.patch
    cvs-1.11.22-cvspass.patch
    cvs-1.11.22-ipv6-proxy.patch
    cvs-1.11.22-stdinargs.patch
    cvs-1.11.23-Back-port-KeywordExpand-configuration-keyword.patch
    cvs-1.11.23-cve-2010-3846.patch
    cvs-1.11.23-Fix-proxy-response-parser.patch
    cvs-1.11.23-getline64.patch
    cvs-1.11.23-make_make_check_sanity_testing_verbose.patch
    cvs-1.11.23-Pass-server-IP-address-instead-of-hostname-to-GSSAPI.patch
    cvs-1.11.23-remove_undefined_date_from_cvs_1_header.patch
    cvs-1.11.23-sanity.patch
    cvs-1.11.23-doc-Add-mandatory-argument-to-sp.patch
    )
md5sums=('0213ea514e231559d6ff8f80a34117f0'
         'e447b7d85674ae63bef7036fc7b2b669'
         '41edb97470e684fc6a7d1d17f5d340be'
         'f882e8c94cb052c3082cb6ea71cf0593'
         '67979fb76f77171e7ce0ea309a312695'
         'd55561000f4b68f3a8839dbdd2b4d85c'
         '13b94678d134fa3c09f57f4d3a901e07'
         '121eb89cb71b72171b6e4db2fc5cec09'
         '2c4f19a8065c87ed294ec28e061c3df5'
         '018571dc8cbbfd84305ee6b4aa070464'
         '1220bc57bf535ce30f800c05b6f8cc4a'
         '6a4d53e35c0e676ec3319e63b124f093'
         '1dda83b84e55bd68bc038f78eea315d1'
         '444ff8ee039c7d3acd12803054166034'
         '510061aeccfa11206ac2ba007c07a04c'
         'b8ceb38f9f7447aa664f43f2cd113f83'
         'fd9d97f8ca16f4fe484afa910d657b26'
         'b089d3792c225857f00c3eee33809a16'
         'af3ba42367213cc51c9401516ce363a7'
         '943f10d93fbadaea0ac54553dd85c03f'
         'cf798718d3c7d4bc5ba510df38b5bd34'
         '1487644a1062f58a6eedb54eaea7e012'
         'adc404214d4061a8cb48c801b718a0ad'
         '8432bdb38ceb9d8375c51846772a4366'
         'cbeb735e8218837429ae98794ec6ff54')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/cvs-1.11.22-cvspass.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-extzlib.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-netbsd-tag.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-abortabort.patch
  patch -p1 -i ${srcdir}/cvs-1.11.1p1-bs.patch
  patch -p1 -i ${srcdir}/cvs-1.11.21-proxy.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-logmsg.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-tagname.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-comp.patch
  patch -p1 -i ${srcdir}/cvs-1.11.19-tmp.patch
  patch -p1 -i ${srcdir}/cvs-1.11.21-diff.patch
  patch -p1 -i ${srcdir}/cvs-1.11.21-diff-kk.patch
  patch -p1 -i ${srcdir}/cvs-1.11.21-sort.patch
  patch -p1 -i ${srcdir}/cvs-1.11.22-ipv6-proxy.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-getline64.patch
  patch -p1 -i ${srcdir}/cvs-1.11.22-stdinargs.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-cve-2010-3846.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-remove_undefined_date_from_cvs_1_header.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-sanity.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-make_make_check_sanity_testing_verbose.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-Back-port-KeywordExpand-configuration-keyword.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-Pass-server-IP-address-instead-of-hostname-to-GSSAPI.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-Fix-proxy-response-parser.patch
  patch -p1 -i ${srcdir}/cvs-1.11.23-doc-Add-mandatory-argument-to-sp.patch
  autoreconf -vfi

  #patch -Np1 < ../cvs-1.11.19-extzlib.patch
  #patch -Np1 < ../cvs-1.11.23-getline64.patch
  # CVE-2010-3864, https://www.redhat.com/security/data/cve/CVE-2010-3846.html
  #patch -Np1 < ../cvs-1.11.23-cve-2010-3846.patch

  sed -i -e 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.in
  find . -name Makefile.am | xargs sed -i -e 's/^INCLUDES/AM_CPPFLAGS/'
  AUTOMAKE='automake --add-missing' autoreconf
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  unset EDITOR VISUAL

  ./configure --prefix=/usr
  make
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  rm "${pkgdir}"/usr/share/info/dir
}
